package com.paic.icore.test.demo.enums;

/**
 * describe:
 *
 * @author huxingjie
 * @date 2019/05/27
 * @since 3.6
 */

import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;

/**
 * VIPER平台支持物体对象类型. ObjectType与字符串表示的标准映射如下见对应枚举项注释.   - OBJECT_UNKNOWN: unknown. 未知.  - OBJECT_FACE: face. 人脸. 输入和输出类型,输入类型用于创建任务时的枚举,输出类型用于输出数据对象的枚举.  - OBJECT_PEDESTRIAN: pedestrian. 行人. 仅为输出类型 [SINCE v1.4.0].  - OBJECT_AUTOMOBILE: automobile. 机动车. 仅为输出类型 [SINCE v1.4.0].  - OBJECT_CYCLIST: cyclist. 骑手. 仅为输出类型 [SINCE v1.4.0].  - OBJECT_HUMAN_POWERED_VEHICLE: human_powered_vehicle. 非机动车. 仅为输出类型 [SINCE v1.4.0].  - OBJECT_SCENARIO: scenario. 场景识别. 仅为输出类型 [SINCE v2.0.0].  - OBJECT_CROWD: crowd. 人群识别. 输入和输出类型 [SINCE v2.0.0].  - OBJECT_MULTI_PACH: pedestrian+automobile+cyclist+human_powered_vehicle. 仅为输入类型 [SINCE v1.4.0].  - OBJECT_SCENARIO_CITY_MANAGEMENT: city management scenario. 城管类场景. 仅为输入类型 [SINCE v2.0.0].
 */
@JsonAdapter(CommonapisObjectType.Adapter.class)
public enum CommonapisObjectType {

    UNKNOWN("OBJECT_UNKNOWN"),

    FACE("OBJECT_FACE"),

    PEDESTRIAN("OBJECT_PEDESTRIAN"),

    AUTOMOBILE("OBJECT_AUTOMOBILE"),

    CYCLIST("OBJECT_CYCLIST"),

    HUMAN_POWERED_VEHICLE("OBJECT_HUMAN_POWERED_VEHICLE"),

    SCENARIO("OBJECT_SCENARIO"),

    CROWD("OBJECT_CROWD"),

    MULTI_PACH("OBJECT_MULTI_PACH"),

    SCENARIO_CITY_MANAGEMENT("OBJECT_SCENARIO_CITY_MANAGEMENT");

    private String value;

    CommonapisObjectType(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }

    public static CommonapisObjectType fromValue(String text) {
        for (CommonapisObjectType b : CommonapisObjectType.values()) {
            if (String.valueOf(b.value).equals(text)) {
                return b;
            }
        }
        return null;
    }

    public static class Adapter extends TypeAdapter<CommonapisObjectType> {
        @Override
        public void write(final JsonWriter jsonWriter, final CommonapisObjectType enumeration) throws IOException {
            jsonWriter.value(enumeration.getValue());
        }

        @Override
        public CommonapisObjectType read(final JsonReader jsonReader) throws IOException {
            String value = jsonReader.nextString();
            return CommonapisObjectType.fromValue(String.valueOf(value));
        }
    }
}



    